
#include <stm32g4xx.h>
#include "pcanpro_timestamp.h"

extern TIM_HandleTypeDef htim6;
extern TIM_HandleTypeDef htim7;
volatile uint32_t timestep = 0;
volatile static uint32_t time7Int = 0;

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	if(htim->Instance==TIM6)
	{
		timestep++;
	}
	else if(htim->Instance==TIM7)
	{
		time7Int++;
	}

	
}

uint32_t pcan_timestamp_millis( void )
{
  return  HAL_GetTick();
}

uint32_t pcan_timestamp_us( void )
{
	return (uint32_t)(__HAL_TIM_GET_COUNTER(&htim7) + (time7Int<<16));
}

